package com.smart_environmental_protection.controller;

import com.smart_environmental_protection.pojo.Purpose;
import com.smart_environmental_protection.pojo.User;
import com.smart_environmental_protection.service.PurposeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@RestController
public class PurposeController {
    @Autowired
    private PurposeService purposeService;

    @GetMapping("/system/type/list")
    public Map<String,Object> purList(){
        Map map=new HashMap<String,Object>();
        List<Purpose> purposeList=purposeService.purList();

        if (purposeList!=null){
            map.put("success",true);
            map.put("msg","成功");
            map.put("code",200);
            map.put("data",purposeList);
        }else {
            map.put("success",false);
            map.put("msg","失败");
        }
        return map;
    }
    @GetMapping("/system/purpose/{id}")
    public Map<String,Object> purDetail(@PathVariable Integer id){
        Map map=new HashMap<String,Object>();
        Purpose purpose=purposeService.purDetail(id);

        if (purpose!=null){ map.put("success",true);
            map.put("msg","成功");
            map.put("code",200);
            map.put("data",purpose);
        }else {
            map.put("success",false);
            map.put("msg","失败");
        }
        return map;
    }
}
